package com.ruoyi.web.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.admin.domain.TdmCmchplc;
import com.ruoyi.web.admin.service.ITdmCmchplcService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * cmc_hplcController
 * 
 * @author ly
 * @date 2022-03-10
 */
@RestController
@RequestMapping("/admin/cmchplc")
public class TdmCmchplcController extends BaseController
{
    @Autowired
    private ITdmCmchplcService tdmCmchplcService;

    /**
     * 查询cmc_hplc列表
     */
    @PreAuthorize("@ss.hasPermi('admin:cmchplc:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmCmchplc tdmCmchplc)
    {
        startPage();
        List<TdmCmchplc> list = tdmCmchplcService.selectTdmCmchplcList(tdmCmchplc);
        return getDataTable(list);
    }

    /**
     * 导出cmc_hplc列表
     */
    @PreAuthorize("@ss.hasPermi('admin:cmchplc:export')")
    @Log(title = "cmc_hplc", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmCmchplc tdmCmchplc)
    {
        List<TdmCmchplc> list = tdmCmchplcService.selectTdmCmchplcList(tdmCmchplc);
        ExcelUtil<TdmCmchplc> util = new ExcelUtil<TdmCmchplc>(TdmCmchplc.class);
        util.exportExcel(response, list, "cmc_hplc数据");
    }

    /**
     * 获取cmc_hplc详细信息
     */
    @PreAuthorize("@ss.hasPermi('admin:cmchplc:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmCmchplcService.selectTdmCmchplcById(id));
    }

    /**
     * 新增cmc_hplc
     */
    @PreAuthorize("@ss.hasPermi('admin:cmchplc:add')")
    @Log(title = "cmc_hplc", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmCmchplc tdmCmchplc)
    {
        return toAjax(tdmCmchplcService.insertTdmCmchplc(tdmCmchplc));
    }

    /**
     * 修改cmc_hplc
     */
    @PreAuthorize("@ss.hasPermi('admin:cmchplc:edit')")
    @Log(title = "cmc_hplc", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmCmchplc tdmCmchplc)
    {
        return toAjax(tdmCmchplcService.updateTdmCmchplc(tdmCmchplc));
    }

    /**
     * 删除cmc_hplc
     */
    @PreAuthorize("@ss.hasPermi('admin:cmchplc:remove')")
    @Log(title = "cmc_hplc", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmCmchplcService.deleteTdmCmchplcByIds(ids));
    }
}
